import 'package:bike_ride/common/mvvm/base_page.dart';
import 'package:bike_ride/common/util/account_manager.dart';
import 'package:bike_ride/common/util/hysize_fit.dart';
import 'package:bike_ride/common/widget/xb_button.dart';
import 'package:bike_ride/model/entrance/view_model/entrance_vm.dart';
import 'package:bike_ride/router/navigator_util.dart';
import 'package:bike_ride/router/routers.dart';
import 'package:flutter/material.dart';

///入口或引导页
class EntranceView extends BaseStatefulPage<EntranceViewModel> {
  const EntranceView({super.key});

  @override
  EntranceViewState createState() => EntranceViewState();
}

class EntranceViewState
    extends BaseStatefulPageState<EntranceView, EntranceViewModel> {
  @override
  void initAttribute() {}

  @override
  void initObserver() {}

  @override
  EntranceViewModel viewBindingViewModel() {
    return EntranceViewModel()..viewState = this;
  }

  @override
  Widget appBuild(BuildContext context) {
    return Scaffold(
        extendBodyBehindAppBar: true,
        body: Column(
          children: [
            Image.asset(
              'assets/common_v2/helmet_banner.png',
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height / 2,
              fit: BoxFit.cover,
            ),
            Expanded(child: Container(
              color: Theme.of(context).colorScheme.primary.withOpacity(0.65),
              width: MediaQuery.of(context).size.width,
              padding: EdgeInsets.only(bottom: 80.rpx),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.end,
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisSize: MainAxisSize.min,
                children: [
                  Text(
                    'Welcome to BikeRide',
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 48.rpx,
                        fontWeight: FontWeight.w500),
                  ),
                  RichText(
                    textAlign: TextAlign.center,
                    text: TextSpan(
                      children: [
                        const TextSpan(text: 'Join now for the most '),
                        TextSpan(
                            text: 'fun,\naffordable ',
                            style: TextStyle(
                                fontSize: 38.rpx,
                                fontWeight: FontWeight.w500)),
                        const TextSpan(text: 'and'),
                        TextSpan(
                            text: ' eco-friendly',
                            style: TextStyle(
                                fontSize: 38.rpx,
                                fontWeight: FontWeight.w500)),
                        const TextSpan(text: ' way\nto get around town'),
                      ],
                      style:
                      TextStyle(color: Colors.white, fontSize: 32.rpx),
                    ),
                  ),
                  SizedBox(
                    height: 80.rpx,
                  ),
                  XbButton(
                    width: 120.rpx,
                    borderRadius: BorderRadius.all(Radius.circular(60.rpx)),
                    isDefault: true,
                    onPressed: () {
                      AccountManager.updateIsFirstOpen(false);
                      NavigatorUtil.push(context, Routers.loginView);
                    },
                    child: Padding(
                      padding: EdgeInsets.symmetric(horizontal: 60.rpx),
                      child: Text(
                        'Start now',
                        style: TextStyle(fontSize: 38.rpx),
                      ),
                    ),
                  )
                ],
              ),
            ))
          ],
        ));
  }
}
